"""配置管理模块"""
import os
from dataclasses import dataclass, field
from pathlib import Path

@dataclass
class Config:
    """编译配置类"""
    # 基本配置
    keep_source: bool = False
    output_dir: Path = None
    verbose: bool = False
    optimize_level: int = 0
    
    # 编译选项
    language_level: int = 3
    extra_compile_args: list = field(default_factory=list)
    extra_link_args: list = field(default_factory=list)
    
    # 平台相关默认值
    def __post_init__(self):
        if os.name == "posix":
            self.extra_compile_args.extend(["-fPIC"])
        if self.optimize_level > 0:
            self.extra_compile_args.extend([f"-O{self.optimize_level}"])
